package com.sun.springboot_mq.hello.sender;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author shkstart
 * @create 2021-10-24 17:48
 */
@Component
public class HelloSender {
    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send(){
        String message="hello "+new Date();
        System.out.println("Send发送方:"+message);
        this.rabbitTemplate.convertAndSend("hello",message);
    }
    public void send(int i){
        String message="hello "+i;
        System.out.println("Send发送方:"+message);
        this.rabbitTemplate.convertAndSend("hello",message);
    }
}
